package com.hoki.zj.hrm.controller;

import com.hoki.zj.hrm.service.IVerifyCodeService;
import com.hoki.zj.hrm.utils.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/verifycode")
public class VerifyCodeController {

    /** 注入IVerifyCodeService */
    @Autowired
    private IVerifyCodeService verifyCodeService;

    /**
     * 1.获取图片验证码
     * @param imageCodeKey imageCodeKey
     * @return
     */
    @GetMapping("/imageCode/{imageCodeKey}")
        public AjaxResult getPictureVerifyCode(@PathVariable("imageCodeKey") String imageCodeKey) {
        String imageCode = verifyCodeService.getPictureVerifyCode(imageCodeKey);
        return AjaxResult.me().setResultObj(imageCode);
    }

    /**
     * 2.获取手机验证码
     * @param map mobile  imageCode  imageCodeKey codeType
     * @return  smsCode
     */
    @PostMapping("/sendSmsCode")
    public AjaxResult getSmsVerifyCode(@RequestBody Map<String, String > map) {
        verifyCodeService.getSmsVerifyCode(map);
        return AjaxResult.me();
    }
}
